package com.sunyy.codegenerator.config;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author sunyy
 * @since 2025/7/17
 */
@Data
@Configuration
@ConditionalOnProperty("minio.enable")
@ConfigurationProperties(prefix = "minio")
public class MinIOConfig {
    /**
     * minio地址
     */
    private String endpoint;
    /**
     * minio用户名
     */
    private String accessKey;
    /**
     * minio密码
     */
    private String secretKey;
    /**
     * 是否启用
     */
    private Boolean enable;

    @Bean(name = "minioClient")
    public MinioClient minioClient() {
        return MinioClient.builder()
                .endpoint(endpoint)
                .credentials(accessKey, secretKey)
                .build();
    }
}
